var Course = { 
	item: null,
	init: function() {
		$ajax({
			url: "/course/list",
			data: {},
			success: function(res) {
				var items = res.result.results;
				SetLS("clist", items);
				var html = "";
				for (var i=0; i<items.length; ++i) {
					var photo = items[i].photo?Core.id2url(items[i]):"../img/icon_course.png";
					var tip = CurrentUser.category==30?"描述:"+items[i].desc:"Description:" + items[i].desc;
					html += '<div class="ub up_list" ontouchstart="zy_touch()" onclick="Course.switch()">'+
					        //'    <div class="uw3 uh3 ub_img_cover" style="background-image:url('+ photo +')"></div>'+
					        '    <div class="">+</div>'+
					        '    <div class="ub-f1 ub ub-ver upl_p5">'+
					        '        <div class="ub-f1 ub">'+
					        '            <div class="ub-f1 ub_left wb_c">'+ items[i].name +'</div>'+
					        '        </div>'+
					        '    </div>'+
					        '</div>';

					var chapter = items[i].chapter;
					html += '<div class="hide ufp9 upl_5">';
					for (var j=0; j<chapter.length; j++) {
					    var tip = CurrentUser.category==30?"描述:"+chapter[j].desc:"Description:" + chapter[j].desc;
						html += '<div class="up_list childctn ub_center" data-pos="'+ j +'" ontouchstart="zy_touch()" onclick="Course.jump(\''+ i +'\', \''+ j +'\');">'+
						        '    <div class="ub-f1 ub ub-ver upl_p5">'+
						        '        <div class="ub-f1 ub">'+
						        '            <div class="ub-f1 ub_left wb_c">'+ chapter[j].name + '</div>'+
						        '        </div>'+
						        '    </div>'+
						        '</div>';
					}
					html += '</div>';					        
				}
				$("#ctn").html(html);
			}
		});
	},	
	switch: function(){
		var $this = $(event.currentTarget);
		$this.next().toggleClass("hide").siblings().addClass("hide");
	},	
	jump: function(i, j){
		var items = GetLS("clist");
		var video = items[i].chapter[j].video;
		if(video)
			uexVideo.open(video, 1);
	},
}